import 'package:flutter/material.dart';

class ButtonDemo extends StatelessWidget {
  const ButtonDemo({super.key});

  @override
  Widget build(BuildContext context) {
    final Widget FlatButtonDemo = Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        TextButton(
          child: Text('Buttom'),
          onPressed: () {},
          style: ButtonStyle(
            backgroundColor: MaterialStateProperty.all(Colors.blue),
          ),
        ),
        SizedBox(width: 20.0),
        TextButton.icon(
          icon: Icon(Icons.add),
          label: Text('Buttom',
              style: TextStyle(color: Theme.of(context).colorScheme.primary)),
          onPressed: () {},
        )
      ],
    );

    final Widget ElevatedButtonDemo = Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        ElevatedButton(
          child: Text('Buttom'),
          onPressed: () {},
          style: ElevatedButton.styleFrom(
              primary: Colors.blue,
              onPrimary: Colors.red,
              elevation: 4.0,
              shape: StadiumBorder() //形状
              ),
        ),
        SizedBox(width: 20.0),
        ElevatedButton.icon(
          icon: Icon(Icons.add),
          label: Text('Buttom',
              style: TextStyle(color: Theme.of(context).primaryColor)),
          onPressed: () {},
        )
      ],
    );
    
    final Widget FixButtonDemo = Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Expanded(
          //最大化 相当于 flex:1
          child: OutlinedButton(
            onPressed: () {},
            child: Text('Buttom'),
            style: ButtonStyle(
              textStyle: MaterialStateProperty.all(TextStyle(fontSize: 15.0)),
              backgroundColor: MaterialStateProperty.all(Colors.red),
            ),
          ),
        ),
        SizedBox(width: 20.0),
        Expanded(
          child: OutlinedButton(
            onPressed: () {},
            child: Text('Buttom'),
            style: ButtonStyle(
              textStyle: MaterialStateProperty.all(TextStyle(fontSize: 15.0)),
              backgroundColor: MaterialStateProperty.all(Colors.red),
            ),
          ),
        ),
      ],
    );

    final Widget ButtonBarDemo = Row( //2个button 放一排了
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Theme(
            data: Theme.of(context).copyWith(
                buttonTheme: ButtonThemeData(
                    padding: EdgeInsets.symmetric(horizontal: 32.0))),
            child: ButtonBar(
              children: [
                OutlinedButton(
                  onPressed: () {},
                  child: Text('Buttom1'),
                  style: ButtonStyle(
                    textStyle:
                        MaterialStateProperty.all(TextStyle(fontSize: 15.0)),
                    backgroundColor: MaterialStateProperty.all(Colors.red),
                  ),
                ),
                OutlinedButton(
                  onPressed: () {},
                  child: Text('Buttom2'),
                  style: ButtonStyle(
                    textStyle:
                        MaterialStateProperty.all(TextStyle(fontSize: 15.0)),
                    backgroundColor: MaterialStateProperty.all(Colors.red),
                  ),
                ),
              ],
            ))
      ],
    );

    return Scaffold(
      appBar: AppBar(
        title: Text('ButtonDemo'),
        elevation: 0.0,
      ),
      body: Container(
        padding: EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            FlatButtonDemo,
            ElevatedButtonDemo,
            FixButtonDemo,
            ButtonBarDemo
          ],
        ),
      ),
    );
  }
}